A semaphore provides a logical mechanism by which access to a shared resource may be controlled. When a process seeks to gain access to a shared resource, the process may first check to see if a semaphore currently allows the use of the shared resource. The semaphore may keep a count that indicates the number of units of the shared resource that are available. If the count is greater than zero, it indicates that at least one unit of the shared resource is available.
A process may need a number of resources to complete certain work. If the semaphore indicates that a sufficient number of units of the resource are available for use by the process, the count associated with the semaphore may be decremented by the number of units the process needs. After the process is finished with the resource, the process may release the units and the semaphore may be incremented by the number of units released.
The subject matter claimed herein is not limited to embodiments that solve any disadvantages or that operate only in environments such as those described above. Rather, this background is only provided to illustrate one exemplary technology area where some embodiments described herein may be practiced.